package com.gary;

import java.util.regex.Pattern;

/**
 * @author peng_rui
 * @date 2023/1/16
 */
public class RegexTest {

    public static void main(String[] args) {

        //^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]
        //^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,}$
        String str1 = "aAsdsdsdsdsd2%";
        String str2 = "ascseAgrs2s$";
        String regex1 = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[$@$!%*?&])[A-Za-z\\d$@$!%*?&]{8,}";
        String regex2 = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[$@$!%*#?&])[A-Za-z\\d$@$!%*#?&]$";

        boolean isMatch1 = Pattern.matches(regex1, str1);
        boolean isMatch2 = Pattern.matches(regex2, str2);

        System.out.println("str1 is match : " + isMatch1);
        System.out.println("str2 is match : " + isMatch2);
    }
}
